var seneca = require("seneca")();
seneca.use("./plugin");
seneca.use('basic')
.use('entity')
seneca.use("mongo-store", {
    name: 'seneca',
    host: '127.0.0.1',
    port: 27017,
    options: {}
});

const SenecaWeb = require('seneca-web')
const Express = require('express')
var express = Express();

express.use(require("body-parser").json());

// This is how you integrate Seneca with Express
seneca.use(SenecaWeb, {
    context: express,
    adapter: require('seneca-web-adapter-express'),
    // defaults --
    options: {
        parseBody: true,
        includeRequest: true,
        includeResponse: true
    }
})



seneca.ready(function (err) {
    seneca.act('role:web', {
        routes: [{
            prefix: '/products',
            pin: 'area:product,action:*',
            map: {
                fetch: { GET: true },
                edit: { GET: false, POST: true },
                delete: { GET: false, DELETE: true }
            }
        }]
    });
    const app = seneca.export('web/context')()
    app.listen(3000)
});
